$(document).ready(function () {
	
	favItem();
	
	function favItem(){
		$(".category").click(function(){
			var url_data = ({ item_id: $(this).attr("title"), current_action: $("#current_action").val() }); 
			$.ajax({
				url: "index.php?type=change_fav",
				type: "POST",
				data: url_data,
				success: function(msg){
					var return_result = jQuery.parseJSON( msg );
					$("#news_box").html(return_result.data);
					favItem();
				}
			});	
		});
	}
	
	$(".change_site").click(function(){
		var url_data = ({ site_id: $(this).attr("title") }); 
		var aTag = $(this);
		$.ajax({
			url: "index.php?type=change_site",
			type: "POST",
			data: url_data,
			success: function(msg){
				var return_result = jQuery.parseJSON( msg );
				if(return_result.status == 'success'){
					if(aTag.hasClass("selected")){
						aTag.removeClass("selected");
					} else {
						aTag.addClass("selected");
					}
				}
			}
		});	
	});
	
	$("#show_select_site").colorbox({
		inline:true, 
		href:"#select_site_block",
		width:"80%",
		overlayClose: false,
		onLoad: function() {
		    $('#cboxClose').remove();
		}
	});
});
